
//气球
var heartObj = function(){
    this.alive = [];
    this.ctx = ctxMain;
    this.a = [];
    this.x = [];
    this.y = [];
    this.r = [];
    this.color = [];
    this.speedX = [];
    this.speedY = [];
    this.offset = [];
    this.alpha = [];
};
heartObj.prototype.num = 10;
heartObj.prototype.currentNum = 0;
heartObj.prototype.total = 50;
heartObj.prototype.init = function(){
    for(var i = 0; i < this.total; i++){
        this.alive[i] = false;
        this.alpha[i] = 1;
    }
    this.color = new Image;
    this.color.src = "img/heart.png"
};
heartObj.prototype.draw = function(){
    for(var i = 0; i < this.total; i++){
        if(this.alive[i]){
            this.y[i] -= this.speedY[i];
            this.alpha -= deltaTime*0.0005;
            this.ctx.drawImage(this.color, this.x[i], this.y[i], this.r[i], this.r[i]);
            if(this.y[i] < -140 || this.x[i] < -100){
                this.alive[i] = false;
            }
        }
    }
};
heartObj.prototype.born = function(x, y, r) {
    for(var i = 0; i < this.num; i++){
        var c = this.currentNum;
        this.alive[c] = true;
        this.x[c] = utils.getRandom(x - r, x + r);
        this.a[c] = 0.01;
        this.y[c] = utils.getRandom(y - r, y + r);
        this.r[c] = 15 + 5*Math.random();
        this.speedY[c] = 0.5*Math.random() + 2.5;
        this.currentNum++;
        if(this.currentNum == this.total) this.currentNum = 0;
    }
};